#ifndef SIMPLEMUTEX_H_
#define SIMPLEMUTEX_H_

#include <pthread.h>

class simpleMtx
{

  pthread_mutex_t mtx; 
  pthread_cond_t cond;

 public:
  simpleMtx() {
    pthread_mutex_init(&mtx, 0);
    pthread_cond_init(&cond, 0);
  }

  virtual ~simpleMtx() {
    pthread_mutex_destroy(&mtx);
    pthread_cond_destroy(&cond);
  }

  void lock() {int ret = pthread_mutex_lock(&mtx); assert(ret==0);}
  void unlock() {int ret = pthread_mutex_unlock(&mtx); assert(ret==0);}
  void wait() {pthread_cond_wait(&cond, &mtx);}
  void notify() {pthread_cond_signal(&cond);}
  void notifyAll() {pthread_cond_broadcast(&cond);}

};

#endif // SIMPLEMUTEX_H_
